import React, { Component } from 'react'

export default class FormDemo2 extends Component {
  login=()=>{
    console.log('姓名:',this.userName.value);
    console.log('密码:',this.password.value);
  }
  render() {
    return (
      <div>
          <form action="#" onSubmit={this.login}>
            <div>
                <label htmlFor="userName">姓名:</label>
                <input type="text" id='userName' ref={arg=>this.userName=arg}/>
            </div>
            <div>
                <label htmlFor="password">密码:</label>
                <input type="text" id='password' ref={arg=>this.password=arg}/>
            </div>
            <div>
                <input type='submit' value={"提交"}></input>
            </div>
        </form>        
      </div>
    )
  }
}
